import { fileURLToPath, URL } from 'node:url'
import checker from 'vite-plugin-checker'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import { VarletUIResolver } from 'unplugin-vue-components/resolvers'

export const devConfig = {
  plugins: [
    vue(),
    Components({
      resolvers: [VarletUIResolver()]
    }),
    AutoImport({
      imports: [
        'vue',
        'pinia',
        'vue-router',
        {
          nprogress: ['start', 'done', 'isStarted']
        }
      ],
      dts: true,
      dirs: ['./src/pinia/**', './src/components/**/*', './src/hooks/*.ts', './src/utils/*.ts'],
      resolvers: [VarletUIResolver({ autoImport: true })]
    }),
    checker({
      typescript: true,
      terminal: true,
      vueTsc: true
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    host: true,
    open: true,
    proxy: {
      '/accompany': {
        target: 'http://222.85.34.143:8674/'
        // changeOrigin: true
      }
    }
  }
}

export default devConfig
